#include <func.h>

int main(int argc,char **argv)
{
    int shmid = 0;
    shmid = shmget(1000,1024,IPC_CREAT|0600);
    ERROR_CHECK(shmid,-1,"shmget");
    char *p =(char*) shmat(shmid,NULL,0);
    ERROR_CHECK(p,(char*)-1,"shmat");
    if(!fork())
    {
        strcpy(p,"How old are you");
        printf("child : i am writing in shm\n");
        return 0;
    }
    else
    {
        wait(NULL);
        printf("parent: str in shm : %s\n",p);
        
        int ret = shmdt(p);
        ERROR_CHECK(ret,-1,"shmdt");
        printf("shmdt success\n");
    }
    return 0;
}

